/*
 * 文件名：PushParkLot.java	 
 * 时     间：下午7:11:21
 * 作     者：Administrator       
 * 版     权： 2012-2022 湖南智软网络科技, 公司保留所有权利.
 * 联     系：http://www.073586.com/
 */
package com.local.manager.thread;

import java.util.List;

import com.cloud.threads.SetRuleCopyRunble;
import com.cz073586.tools.util.ThreadPoolUtil;
import com.local.entity.vo.CarParkInOverVo;
import com.local.manager.cfgManager.CloudConfigManager;
import com.local.model.LocalChargeBytimeCopy;
import com.local.service.face.LocalChargeByTimeCopyService;
import com.local.service.face.LogService;
import com.qianhai.common.utils.Log4jUtil;

/**
 * 类描述:推送车位信息,车位总数减去在场车辆
 * 
 * @ClassName: PushParkLot
 * @author Administrator
 * @date 2015年9月29日 下午7:11:21
 */
public class ChargeBytimeThread implements Runnable
{
	private static Log4jUtil log = Log4jUtil.getLog4j(ChargeBytimeThread.class);
	
	private CarParkInOverVo cv;
	
	private LocalChargeByTimeCopyService localChargeByTimeCopyService;
	
	private LogService logService;
	
	
	
	public ChargeBytimeThread(CarParkInOverVo cv,LocalChargeByTimeCopyService localChargeByTimeCopyService,LogService logService)
	{
		super();
		this.cv = cv;
		this.localChargeByTimeCopyService = localChargeByTimeCopyService;
		this.logService = logService;
	}



	@Override
	public void run()
	{
		
		try
		{
			List<LocalChargeBytimeCopy> lis = localChargeByTimeCopyService
					.addRuleCopy(cv.getCarparkIn());
			// 计费规则副本放入云端
			for (LocalChargeBytimeCopy localChargeBytimeCopy : lis)
			{
				// 计费副本表，放入云平台副本表
				if (CloudConfigManager.instance().isOpen())
				{
					SetRuleCopyRunble upload = new SetRuleCopyRunble(
							localChargeBytimeCopy, logService);
					ThreadPoolUtil.instance().execute(upload);
				}
			}
		} catch (Throwable e)
		{
			log.error("", e);
		}
	}
}
